package br.ufrj.dcc.xml.view;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Toolkit;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import java.awt.Insets;
import javax.swing.SwingConstants;

public class Loading extends JDialog {

	private static final long serialVersionUID = 1L;
	
	private JPanel contentPanel = null;

	private JProgressBar jProgressBar = null;

	private JLabel textLabel = null;

	/**
	 * This method initializes 
	 * 
	 */
	public Loading(Frame owner) {
		super(owner, true);
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
        this.setSize(new Dimension(523, 207));
        this.setPreferredSize(new Dimension(523, 207));
        this.setMinimumSize(new Dimension(523, 207));
        this.setTitle("Operação em progresso...");
        this.setContentPane(getContentPanel());
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();         
        int x = (screenSize.width - this.getWidth()) / 2;
        int y = (screenSize.height - this.getHeight()) / 2;

        this.setLocation(x, y); 			
	}

	/**
	 * This method initializes contentPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getContentPanel() {
		if (contentPanel == null) {
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.insets = new Insets(1, 0, 0, 0);
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
			gridBagConstraints1.weightx = 1.0;
			gridBagConstraints1.gridy = 0;
			textLabel = new JLabel();
			textLabel.setText("");
			textLabel.setHorizontalAlignment(SwingConstants.CENTER);
			textLabel.setHorizontalTextPosition(SwingConstants.CENTER);
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
			gridBagConstraints.weightx = 1.0;
			gridBagConstraints.gridy = 1;
			contentPanel = new JPanel();
			contentPanel.setLayout(new GridBagLayout());
			contentPanel.add(getJProgressBar(), gridBagConstraints);
			contentPanel.add(textLabel, gridBagConstraints1);
		}
		return contentPanel;
	}

	/**
	 * This method initializes jProgressBar	
	 * 	
	 * @return javax.swing.JProgressBar	
	 */
	private JProgressBar getJProgressBar() {
		if (jProgressBar == null) {
			jProgressBar = new JProgressBar();
			jProgressBar.setAutoscrolls(true);
			jProgressBar.setIndeterminate(true);
		}
		return jProgressBar;
	}

	public JLabel getTextLabel() {
		return textLabel;
	}

}  //  @jve:decl-index=0:visual-constraint="282,167"
